package com.pojo;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

/**
 * zhuji
 * @author zr
 */
@Data
@TableName(value = "zhuji",resultMap = "zhuji")
public class Zhuji implements Serializable {

    @TableId(type = IdType.ASSIGN_ID)
    private String id; //主键，不是自增，是雪花ID

    /**
     * 别名
     */
    private String remarks;

    /**
     * 地址
     */
    private String address;

    /**
     * 端口
     */
    private String port;

    /**
     * uid
     */
    private String uid;

    /**
     * 额外id
     */
    private String out_id;

    /**
     * 类型(0为国内通国外，1为国外通国内，2国内外互通)
     */
    private Integer type;
    /**
     * 状态(0为禁用，1为启用)
     */
    private Integer status;
    /**
     * 到期时间
     */
    private Date end_time;
    /**
     * 提交管理员用户id
     */
    private String admin_id;
    /**
     * 所属地区ID
     */
    private String area_id;
    /**
     * 所属国家ID
     */
    private String country_id;

    /**
     * 最大连接数
     */
    private Integer lianjie_num;
    /**
     * 已连接数
     */
    private Integer sy_lianjie_num;
    /**
     * 版本号
     */
    private String version;
    /**
     * 连接方式(tcp)
     */
    private String net;
    /**
     * 伪装类型
     */
    private String wz_type;

    @TableField(exist = false)
    private Admin admin;  //用户

    @TableField(exist = false)
    private Area area;  //地区

    @Override
    public String toString() {
//        return "{\"v\":\"" + (version == null?"":version) + "\", \"ps\":\"" + (remarks == null?"":remarks) + "\", \"add\":\""
//                + (address== null?"":address) + "\", \"port\":\"" + (port == null?"":port) + "\", \"id\":\"" + (uid == null?"":uid) +"\", \"aid\":\""
//                + (out_id== null?"":out_id) +"\", \"net\":\"" + (net== null?"":net) +
//                "\", \"type\":\"" + (wz_type == null?"":wz_type) +"\", \"host\":\"\",\"path\":\"\",\"tls\":\"\"}";
        String res = "{\n" +
                "\"v\": \"%s\",\n" +
                "\"ps\": \"%s\",\n" +
                "\"add\": \"%s\",\n" +
                "\"port\": \"%s\",\n" +
                "\"id\": \"%s\",\n" +
                "\"aid\": \"%s\",\n" +
                "\"net\": \"%s\",\n" +
                "\"type\": \"%s\",\n" +
                "\"host\": \"\",\n" +
                "\"path\": \"\",\n" +
                "\"tls\": \"\"\n" +
                "}" ;
        return String.format(res,version == null?"":version,remarks == null?"":remarks,address== null?"":address,port == null?"":port,uid == null?"":uid,out_id== null?"":out_id,net== null?"":net,wz_type == null?"":wz_type);
    }

    private static final long serialVersionUID = 1L;
}